package com.csdj.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.LocaleResolver;
import org.springframework.web.servlet.config.annotation.*;

/**
 * Author : 今晚几点睡_Ada
 * Date: 2022/8/2
 * Time: 11:19
 * 注:   扩展springmvc
 */
@Configuration
public class MyMvcConfig implements WebMvcConfigurer {
    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
        registry.addViewController("/index.html").setViewName("index");
        registry.addViewController("/login.html").setViewName("login");
    }

    //登录拦截
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new LoginHandlerInterceptor())
                .addPathPatterns("/**")
                .excludePathPatterns("/",
                        "/toLogin",
                        "/toRegister",
                        "/index.html",
                        "/login.html",
                        "/user/toLogin",
                        "/user/addUser",
                        "/css/**",
                        "/js/**",
                        "/images/**",
                        "/bootstrap3/**");
    }
}
